package com.controller;

import com.pojo.Doctor;
import com.service.impl.DoctorServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (Doctor)表控制层
 *
 * @author makejava
 * @version 1.0
 * @since 2022-04-08 12:33:27
 */
@RestController
@RequestMapping("/doctor")
public class DoctorController {
    /**
     * 服务对象
     */
    @Resource
    private DoctorServiceImpl doctorServiceImpl;

    /**
     * 查询所有数据
     *
     * @return 返回所有数据
     */
    @RequestMapping(value = "/selectAll", method = RequestMethod.GET)
    public Map<String, Object> selectAll() {
        return this.doctorServiceImpl.selectAll();
    }

    /**
     * 通过主键删除单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping(value = "/deleteById", method = RequestMethod.POST)
    public Map<String, Object> deleteById(@RequestParam("id") String id) {
        return this.doctorServiceImpl.deleteById(id);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @RequestMapping(value = "/selectById", method = RequestMethod.GET)
    public Map<String, Object> selectById(String id) {
        return this.doctorServiceImpl.selectById(id);
    }

    /**
     * 通过主键更新单条数据
     *
     * @param doctor 一个数据库对应的POJO数据对象
     * @return 单条数据
     */
    @RequestMapping(value = "/updateById", method = RequestMethod.POST)

    public Map<String, Object> updateById(@RequestBody Doctor doctor) {
        return this.doctorServiceImpl.updateById(doctor);
    }

    /**
     * 通过一个pojo对象新增单条数据
     *
     * @param doctor 一个数据库对应的POJO数据对象
     * @return 返回插入的主键id
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public Map<String, Object> insert(@RequestBody Doctor doctor) {
        return this.doctorServiceImpl.insert(doctor);
    }

}